import Vue from "vue";

import "normalize.css/normalize.css"; // A modern alternative to CSS resets

import "element-ui/lib/theme-chalk/index.css";

import "@/styles/index.scss"; // global css

import App from "./App";
import store from "./store";
import router from "./router";

import "@/icons"; // icon
import "@/permission"; // permission control

import i18n from "./lang";
import Cookies from "js-cookie";
import Element from "element-ui";
// 引入echarts
import * as echarts from "echarts";
Vue.prototype.$echarts = echarts;

import BaiduMap from "vue-baidu-map";

Vue.use(BaiduMap, {
  /* 需要注册百度地图开发者来获取你的ak */
  ak: "sKrOZGXxifZ1r7Ot7Bm1OoBWd6DILGfH"
});

// 全局载入封装的axios
import service from "@/utils/request";
// 将service绑定到vue原型上
Vue.prototype.$service = service;

// 公共url
import { webSerUrlPro, webServiceUrl, webUrl, serviceUrl, agrSocialUrl } from "@/api/baseURL"
Vue.prototype.$zhurl = webServiceUrl;
Vue.prototype.$webSerUrlPro = webSerUrlPro;
Vue.prototype.$webUrl = webUrl;
Vue.prototype.$serviceUrl = serviceUrl;
Vue.prototype.$agrSocialUrl = agrSocialUrl;

// 图片
import EleUploadImage from "vue-ele-upload-image";
Vue.component(EleUploadImage.name, EleUploadImage);
// json 美化
import JsonViewer from 'vue-json-viewer'
Vue.use(JsonViewer)

import moment from "moment"; // 导入moment模块
moment.locale("zh-cn"); // 设置语言 或 moment.lang('zh-cn');
Vue.prototype.$moment = moment; // 赋值使用

Vue.use(Element, {
  size: Cookies.get("size") || "medium", // set element-ui default size
  i18n: (key, value) => i18n.t(key, value)
});
import SearchBox from "@/components/SearchBox";
Vue.component('SearchBox', SearchBox);
Vue.config.productionTip = false;
// 禁止点击空白关闭
Element.Dialog.props.closeOnClickModal.default = false
Vue.prototype.dateToFormat = function (originDate) {
  const dt = new Date(originDate);
  const y = dt.getFullYear();
  const m = (dt.getMonth() + 1 + "").padStart(2, "0");
  const d = (dt.getDate() + "").padStart(2, "0");

  const hh = (dt.getHours() + "").padStart(2, "0");
  const mm = (dt.getMinutes() + "").padStart(2, "0");
  const ss = (dt.getSeconds() + "").padStart(2, "0");

  return `${y}-${m}-${d} ${hh}:${mm}:${ss}`;
};

new Vue({
  el: "#app",
  router,
  store,
  i18n,
  render: h => h(App)
});
